<template>
  <div>
    <div>基础信息</div>
    <div class="pw100 flex_aj column">
      <r-list :ListRows="ListRows" :ListData="ListData"></r-list>
    </div>
    <div class="flex_aj" v-if="ListData.state == 3">
      <el-button
        v-if="$store.state.buttons[1001]"
        @click="enterTakeCash(1)"
        class="mt20"
        type="success"
        >确认提现</el-button
      >
      <el-button
        v-if="$store.state.buttons[1002]"
        @click="enterTakeCash(2)"
        class="mt20"
        type="danger"
        >拒绝提现</el-button
      >
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      ListRows: [
        [
          {
            label: "Order Nnumber",
            prop: "number"
          },
          {
            label: "User账号",
            prop: "theActualAmount"
          },
          {
            label: "Status",
            prop: "state",
            formatter: e =>
              e.state == 1
                ? "Review Pass"
                : e.state == 2
                ? "审核不Pass"
                : e.state == 3
                ? "Pending Review"
                : ""
          },
          {
            label: "Withdrawal Amount(元)",
            prop: "money"
          },
          {
            label: "确认Withdrawal Amount(元)",
            prop: "Entermoney",
            type: "input",
            isShow: e => false
          },
          {
            label: "银行信息",
            prop: "bankInfo",
            formatter: e =>
              e &&
              e.bankInfo &&
              "卡号:" +
                JSON.parse(e.bankInfo).bankCard +
                " 开户支行:" +
                JSON.parse(e.bankInfo).bank +
                " 持卡人:" +
                JSON.parse(e.bankInfo).holder
          },
          {
            label: "提现人",
            prop: "name"
          },
          {
            label: "提现Type",
            prop: "type",
            formatter: e =>
              e.type == 1
                ? "银行卡"
                : e.type == 2
                ? "WeChat"
                : e.type == 3
                ? "Alipay"
                : ""
          },
          {
            label: "处理Remarks",
            prop: "remark",
            type: "input",
            isDisable: e => (e.state == 1 ? true : true)
          }
        ]
      ],
      ListData: {}
    };
  },
  components: {},
  computed: {},
  mounted() {
    this.init();
  },
  methods: {
    async init() {
      let res = await this.api.takecashList({
        number: this.$route.query.number,
        sType: "2"
      });
      if (res) {
        this.ListData = res.data.list[0];
        this.ListData.Entermoney = this.ListData.money;
      }
    },
    // 确认提现
    async enterTakeCash(tp) {
      this.ListData.state = tp; //Status
      // console.log(this.ListData);
      let res = await this.api.withdraw({
        id: this.ListData.id,
        money: this.ListData.Entermoney,
        state: tp,
        remark: this.ListData.remark
      });
      if (res) {
        this.$router.replace("/moneyManagement-takeCash");
      } else {
        this.init();
      }
    },
    // 拒绝提现
    rejectTakeCash() {}
  }
};
</script>
<style scoped lang="scss"></style>
